//
//  HMStatusOriginalView.swift
//  VVeibo21
//
//  Created by apple on 2016/10/27.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class HMStatusOriginalView: UIView {
    
    var statusViewModel:HMStatusViewModel?{
    
        didSet{
            headerImgView.hm_setImage(withUrlString: statusViewModel?.statusModel?.user?.profile_image_url, placeholderImgName: "avatar_default_big")
            nameLabel.text = statusViewModel?.statusModel?.user?.name
            memberShipImgView.image = statusViewModel?.mbrankImage
            avatarImgView.image = statusViewModel?.verifiedImage
            contentLabel.text = statusViewModel?.statusModel?.text
        }
    }
    /*
     
     /// 用户UID
     var id: Int = 0
     /// 友好显示名称
     var name: String?
     /// 用户头像地址（中图），50×50像素
     var profile_image_url: String?
     /// 认证类型 -1：没有认证，1，认证用户，2,3,5: 企业认证，220: 达人
     var verified: Int = 0
     /// 会员等级 1-6
     var mbrank: Int = 0
     
     */

    override init(frame: CGRect) {
        super.init(frame: frame)
    
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // 设置视图
    private func setupUI(){
        
        addSubview(headerImgView)
        addSubview(nameLabel)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(memberShipImgView)
        addSubview(avatarImgView)
        addSubview(contentLabel)
        
        headerImgView.snp_makeConstraints { (make) in
            make.top.left.equalTo(10)
            make.size.equalTo(CGSize(width: 35, height: 35))
        }
        nameLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headerImgView)
            make.left.equalTo(headerImgView.snp_right).offset(10)
        }
        memberShipImgView.snp_makeConstraints { (make) in
            make.left.equalTo(nameLabel.snp_right).offset(10)
            make.centerY.equalTo(nameLabel)
        }
        timeLabel.snp_makeConstraints { (make) in
            make.bottom.equalTo(headerImgView)
            make.left.equalTo(headerImgView.snp_right).offset(10)
        }
        sourceLabel.snp_makeConstraints { (make) in
            make.bottom.equalTo(headerImgView)
            make.left.equalTo(timeLabel.snp_right).offset(10)
        }
        avatarImgView.snp_makeConstraints { (make) in
            make.centerX.equalTo(headerImgView.snp_right)
            make.centerY.equalTo(headerImgView.snp_bottom)
        }
        contentLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headerImgView.snp_bottom).offset(10)
            make.left.equalTo(headerImgView)
            make.bottom.equalTo(self).offset(-10)
        }
        
    }
    
    // 懒加载控件
    private lazy var headerImgView:UIImageView = UIImageView(imgName: "avatar_default_big")
    private lazy var nameLabel:UILabel = UILabel(textColor: UIColor.blue, fontSize: 15, text: "Mark")
    private lazy var timeLabel:UILabel = UILabel(textColor: UIColor.orange, fontSize: 12, text: "时间")
    private lazy var sourceLabel:UILabel = UILabel(textColor: UIColor.darkGray, fontSize: 12, text: "来自：北京市海淀区中关村")
    private lazy var memberShipImgView:UIImageView = UIImageView(imgName: "common_icon_membership")
    private lazy var avatarImgView:UIImageView = UIImageView(imgName: "avatar_vgirl")
    private lazy var contentLabel:UILabel = UILabel(textColor: UIColor.darkGray, fontSize: 14, text: "", MaxWidth: HMSCREENW - 20)
    

}
